package CareerUp.SelectPoint;

import java.util.ArrayList;

/**
 * Implement a method for a web service call that receives a collection of n
 * coordinate points and returns the kth closest point to the origin (0,0). For
 * example, if k=1 the closest point to the origin should be returned. If k=n
 * the furthest point from the origin should be returned. (Use Divide and
 * Conquer Approach looking for implementation in Java)
 * 
 * @author Xi
 * 
 */
public class SelectPoint {

	/**
	 * calculate the distance in constant cost, then use quick select find the
	 * nth large number
	 */

	public static void main(String[] argv) {

		// distance = x^2 + y^2;
		ArrayList<Integer> distances = new ArrayList<Integer>();
		distances.add(11);
		distances.add(22);
		distances.add(33);
		distances.add(44);
		distances.add(144);
		distances.add(244);
		distances.add(4114);
		QuickSelection.quickSelec(distances, 1);

		int res = QuickSelection.getResult();
		System.out.println(res);
	}
}
